//
//  BaseViewController.m
//  拖小延闹钟
//
//  Created by rimi on 15/10/8.
//  Copyright (c) 2015年 Liukai. All rights reserved.
//

#import "BaseViewController.h"
#import "MainViewController.h"

@interface BaseViewController ()
@property (nonatomic, strong) MainViewController *mainVC;
@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initInterface];
}

- (void)initInterface {
    UIView *navBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 64)];
    navBarView.backgroundColor = [UIColor colorWithWhite:0.900 alpha:1.000];
    //title
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetWidth(self.view.bounds) / 2 - 40, 20, 120, 40)];
    titleLabel.text = self.theTitle;
    titleLabel.font = [UIFont systemFontOfSize:22];
    //personalButton
    UIButton *personalButton = [UIButton buttonWithType:UIButtonTypeCustom];
    personalButton.frame = CGRectMake(10, 24, 40, 40);
    [personalButton setImage:[UIImage imageNamed:@"菜单"] forState:UIControlStateNormal];
    [personalButton addTarget:self action:@selector(openAndClose:) forControlEvents:UIControlEventTouchUpInside];
    [navBarView addSubview:personalButton];
    [navBarView addSubview:titleLabel];
    [self.view addSubview:navBarView];
    
}

- (void)openAndClose:(UIButton *)sender {

    if ([ControllerManager shareControllerManager].mainViewController.view.frame.origin.x == 0) {
        [[ControllerManager shareControllerManager].drawViewController openLeftViewController];
    }
    else {
        
        [[ControllerManager shareControllerManager].drawViewController showMainView];
    }
}


@end
